package Exercise;
//将整型数组以字符串形式输出
public class String_0 {
    public static void main(String[] args) {
        int[] arr = {1,2,3};
        String res = Trans(arr);
        System.out.println(res);
    }
    //转换
    public static String Trans(int[] arr){
        //数组没有地址
        if(arr==null)
            return "";
        //数组有地址，但无元素
        if(arr.length==0)
            return "[]";
        String result = "[";
        for (int i = 0; i < arr.length; i++) {
            if(i==arr.length-1){
                result = result + arr[i];
            }else{
                result = result + arr[i] + ",";
            }
        }
        result = result + "]";
        return result;
    }
}
